module py2Obj {


	export class BoomBullet extends basicObj {
		//保存外部的物理世界
		private time: egret.Timer;
		private bulletType: any;
		public isRun = false;
		public pointList: egret.Point[] = [];
		public range: egret.Bitmap;

		public constructor(world: any, gamePanle: any, romveSkins: any) {
			super(world, gamePanle, romveSkins);
			this.objkind = 102;

		}
		public init() {
			super.init();

		}
		public send(x, y, forcex, forcey) {
			this.m_body.type = 1;
			this.isRun = true;
			this.m_body.velocity = [0, 0];
			this.m_body.damping = 0;
			this.setPostion(x, y);
			this.setForce(forcex, forcey);
		}
		public createMyRigidbody(): p2.Body {
			var world: P2World = this.m_world;
			var skin: MImage = this.createSkin("raind_png");//redball_png

			var body: p2.Body = world.createCircleBodyShape(13);
			body.userData.skin = skin;
			body.userData.data = this;
			body.mass = 0;//质量设置为0，就可以按规定方向发射，等发生碰撞之后再给球质量
			//body.gravityScale=0;
			var shape = body.shapes[0];
			shape.collisionGroup = 2;//010与001为0，010与110为1
			return body;

		}


		private createFixedBullet() {

		}
		/**摁第二次进入的方法 */
		public runEnd() {
			SoundControl.getIns().addItem(MUSIC_BaoZha);
			SoundControl.getIns().play(MUSIC_BaoZha, 0, 1);
			GameControl.GameControlSole.bombBlasts(this.m_body.position[0], this.m_body.position[1]);//进入爆炸消除东西的判断方法里
			this.m_body.velocity = [0, 0];
			this.m_body.type = 2;
			this.setPostion(-250, -250);
			this.isRun = false;


		}
		// /** 碰撞到金币进入的方法 */
		public runEnd2() {//（原地生成一个球）
			var bullet = new py2Obj.basicBullet(this.m_world, this.m_gamePanle, this.m_removeSkins);
			bullet.init();
			bullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
			this.m_gamePanle.doMaterial(bullet.getBody());
			// bullet.setForce(this.vec.x, this.vec.y);
			// this.setChildIndex(this.gun, this.numChildren - 1);
			this.m_body.velocity = [0, 0];
			this.m_body.type = 2;
			this.setPostion(-150, -150);
			this.isRun = false;
			GameControl.GameControlSole.crashGold();
			return bullet;

		}
		public recyle() {
			this.isRun = true;
			this.m_body.type = 2;
			this.time = new egret.Timer(50, 1);
			this.time.start();//开始计时
			this.time.addEventListener(egret.TimerEvent.TIMER, this.jishi, this);
		}
		public jishi() {
			this.isRun = true;
			this.m_body.type = 1;
		}
		public runEnd1() {
			this.m_body.type = 3;
			this.isRun = true;
		}
		public strikeRecyle() {
			this.m_body.type = 3;
		}
		// public recyle() {

		// }
		public getCollision(otherBody: basicObj) {
			super.getCollision(otherBody);
			//if (otherBody.objkind == 100||otherBody.objkind == 400) {
			// 	var boombullet = new py2Obj.clrcle(this.m_world, this.m_gamePanle, this.m_removeSkins);
			// 	boombullet.init();
			// 	boombullet.setPostion(this.m_body.position[0], this.m_body.position[1]);
			// 	this.m_gamePanle.doMaterial(boombullet.getBody());
			// 	var timer:egret.Timer=new egret.Timer(200,1);
			// 	timer.start();
			// 	 timer.addEventListener(egret.TimerEvent.TIMER, ()=>{
			//     boombullet.removebullet(boombullet);
			// }, this);
			// }
			if (otherBody.objkind == 401 || otherBody.objkind == 402 || otherBody.objkind == 404 || otherBody.objkind == 405 || otherBody.objkind == 406) {
				this.recyle();
			}
			if (otherBody.objkind == 200 || otherBody.objkind == 201) {
				this.runEnd();
			}
			if (otherBody.objkind == 108) {
				this.strikeRecyle();
			}

		}
	}
}